_Pragma("once");

#include "KeyCode.h"

class KeypadListener {

public:

    /**
     * 按键监听,包括上下页翻页的处理
     @return 0代表没有处理,1代表已处理，2 代表已处理，需要要刷新
     */
    virtual int onKeyPressed(const KeyCode& keyCode) {
        int result = 0;
        switch (keyCode) {
        case KeyCode::DOWN: {
            result = onKeyDown(keyCode);

            break;
        }
        case KeyCode::UP: {
            result = onKeyUp(keyCode);
            break;
        }
        case KeyCode::ENTER: {
            result = onKeyEnt(keyCode);
            break;
        }
        case KeyCode::SET: {
            result = onKeySet(keyCode);
            break;
        }
        default:
         result = onOtherKey(keyCode);
            break;
        }
        return result;
    }


    virtual int onKeyDown(const KeyCode& keyCode) = 0;
    virtual int onKeyUp(const KeyCode& keyCode) = 0;
    virtual int onKeySet(const KeyCode& keyCode) = 0;
    virtual int onKeyEnt(const KeyCode& keyCode) = 0;

    virtual int onOtherKey(const KeyCode& keyCode) = 0;
};

